import {pinyin} from 'pinyin-pro';



export function isHan(char: string): boolean {
    const reg = new RegExp("[\\u4E00-\\u9FFF]+", "g");
    return reg.test(char)
}


// 如果是汉字返回拼音；否则返回原字符
export function getPinyinStr(char: string): string {
    return isHan(char) ? pinyin(char) : char
}


export function getPinyinList(char: string): Array<string> {
    let pinyinStr = getPinyinStr(char);
    if (!pinyinStr || pinyinStr.length < 1) {
        return []
    }
    return pinyinStr.split("");
}
